#include "comm.hpp"

//客户端--负责发消息
int main()
{
    key_t key = Getftok(PATHNAME,PROJ_ID);
    printf("value of key -> %d\n",key);
    int shmid = GetShm(key);  //这里只需要获得shmid即可
    printf("value of shmid -> %d\n",shmid);

    //需要跟共享内存关联上
    char* start = (char*)AttachShm(shmid);
    printf("attach success %p\n",start);
    
    const char* message = " hello this is client speak to you ";
    int pid = getpid();
    int cnt=1;
    int sec=10;
    while(sec--)
    {
        snprintf(start, MAX_SIZE, " %s[pid %d][message num %d] ", message,pid,cnt++);
        sleep(1);
    }
    //去关联
    DtachShm(start);
    //客户端不用去删除共享内存数据，交给server即可
    return 0;

}

